import request from '/@/utils/request.ts'

import { IGoodTypeData, IGoodSpecs, IGoodListData } from '/@/entity/good'

export const defaultGoodTypeData: IGoodTypeData = {
	pid: 0, //父id
	name: '', //名称
	sort: 1, //排序
	state: 1, //状态，1：可用，2：不可用
	desc: '', //描述
	pic: '', //图片，最多一张
	keywords: '' //关键字，最多五个
}

export const defaultGoodSpecs: IGoodSpecs = {
	specsValue: null, //数量
	specsPrice1: null, //商品售价
	specsPrice2: null, //市场价
	specsPrice3: null, //成本价
	specsStock: null, //库存
	specsStockValue: null //预警值
}

export const defaultGoodListData: IGoodListData = {
	//通用信息
	categoryId: null, //商品分类id
	goodsName: '', //商品名称，20个字
	brandName: '', //商品品牌
	yieldly: [], //商品产地
	keywords: '', //商品关键字，最多五个
	price: null, //商品售价
	marketPrice: null, //市场价
	costPrice: null, //成本价
	inventory: null, //库存
	inventoryWarning: null, //库存预警值
	desc: '', //描述
	pic: '', //封面图片，最多6张
	mainPic: '', //封面主图片
	video: '', //视频
	postageType: 3, //运费方式， 1：固定运费，2：模板运费,3:商家包邮
	postageTemplate: null, //模板id
	postage: null, //固定运费
	isComments: 1, //是否可以评论
	shelvesState: 1, //是否上架
	state: 1, //是否显示
	detailsPhone: '', //app详情图片，最多20个
	detailsPhoneDesc: '', //app详情描述
	specialDesc: '', //助力贴士
	//其他信息
	specificationsType: '规格', //属性类型，默认为”规格“
	specificationsInfo: [defaultGoodSpecs], //商品规格
	integral: null, //获得积分
	comments: '', //评论标签
	storeRemark: '' //商家备注
}
//--------------------------------------商品列表---------------------------------------
//获取商品GET /goods/getGoodsList
export const getGoodsList = (data: any): any =>
	request({
		url: '/goods/getGoodsList',
		method: 'get',
		params: data
	})

//根据商品ID获取商品详情	GET /goods/getGoodsInfoById
export const getGoodsInfoById = (data: any): any =>
	request({
		url: '/goods/getGoodsInfoById',
		method: 'get',
		params: data
	})

//添加商品	POST /goods/insertGoods
export const insertGoods = (data: any): any =>
	request({
		url: '/goods/insertGoods',
		method: 'post',
		params: data
	})

//更新商品 POST /goods/updateGoods
export const updateGoods = (data: any): any =>
	request({
		url: '/goods/updateGoods',
		method: 'post',
		params: data
	})

//商品转移分类 POST /category/transferGoodsCategory
export const transferGoodsCategory = (data: any): any =>
	request({
		url: '/category/transferGoodsCategory',
		method: 'post',
		params: data
	})
//--------------------------------------商品分类---------------------------------------
//根据父级ID获取子级列表GET /category/getCategoryListById
export const getCategoryListById = (data: any): any =>
	request({
		url: '/category/getCategoryListById',
		method: 'get',
		params: data
	})

//获取所有分类，含子级
export const getCategoryList = (data: any): any =>
	request({
		url: '/category/getCategoryList',
		method: 'get',
		params: data
	})

//根据ID获取详情 GET /category/getCategoryById
export const getCategoryById = (data: any): any =>
	request({
		url: '/category/getCategoryById',
		method: 'get',
		params: data
	})

//添加一个分类	POST /category/addCategory
export const addCategory = (data: any): any =>
	request({
		url: '/category/addCategory',
		method: 'post',
		params: data
	})

//更新一个分类 POST /category/updateCategory
export const updateCategory = (data: any): any =>
	request({
		url: '/category/updateCategory',
		method: 'post',
		params: data
	})

//删除一个分类 POST /category/delCategoryById
export const delCategoryById = (data: any): any =>
	request({
		url: '/category/delCategoryById',
		method: 'post',
		params: data
	})
